import urllib.parse as up

keyword= '数据分析'

d = {
    'k1':keyword,
    'k2':'机器学习'
}

ret = up.urlencode(d)
print(ret)
'''
k1=%E6%95%B0%E6%8D%AE%E5%88%86%E6%9E%90&k2=%E6%9C%BA%E5%99%A8%E5%AD%A6%E4%B9%A0
'''
#编码
rr = up.urlencode({'k1':keyword})
print(rr)
url='https://search.51job.com/list/010000,000000,0000,00,9,99,{keyword},2,1.html?lang=c&postchannel=0000&workyear=99&cotype=99&degreefrom=99&jobterm=99&companysize=99&ord_field=0&dibiaoid=0&line=&welfare='
print(url.format(keyword=rr))

'''
若不进行编译，requests.get(url=url)时，有可能无法识别
'''

#解码
print(up.unquote(url.format(keyword=rr)))
'''
https://search.51job.com/list/010000,000000,0000,00,9,99,k1=数据分析,2,1.html?lang=c&postchannel=0000&workyear=99&cotype=99&degreefrom=99&jobterm=99&companysize=99&ord_field=0&dibiaoid=0&line=&welfare=

'''
